//js数组

console.log(Array.from("Matt"));

const m = new Map().set(1,2).set(3,4);
console.log(Array.from(m));// [[1, 2], [3, 4]]
/*
//m.set(1,2).set(3,4);与下面2句代码等价
m.set(1, 2);
m.set(3, 4);
*/


const s = new Set().add(1).add(2).add(3).add(4);
console.log(Array.from(s));//// [1, 2, 3, 4]

 // Array.from()对现有数组执行浅复制
 const a1=[1,2,3,4];
 const a2 = Array.from(a1);
 console.log(a2);//[1,2,3,4]
 alert(a1 === a2);//false

 //可以使用任何可迭代对象
 const iter = {
    *[Symbol.iterator]()
    {
        yield 1;
        yield 2;
        yield 3;
        yield 4;
    }
 }